﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace ST.Buz.Base.Migrations
{
    public partial class _1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "IMS_Partner",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CatID = table.Column<int>(nullable: false),
                    Type = table.Column<int>(nullable: false),
                    Code = table.Column<string>(maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 120, nullable: true),
                    PYCode = table.Column<string>(maxLength: 10, nullable: true),
                    Phone = table.Column<string>(maxLength: 30, nullable: true),
                    Fax = table.Column<string>(maxLength: 30, nullable: true),
                    ContactMan = table.Column<string>(maxLength: 20, nullable: true),
                    ContactPhone = table.Column<string>(maxLength: 30, nullable: true),
                    Email = table.Column<string>(maxLength: 50, nullable: true),
                    Country = table.Column<string>(maxLength: 50, nullable: true),
                    Province = table.Column<string>(maxLength: 50, nullable: true),
                    City = table.Column<string>(maxLength: 50, nullable: true),
                    District = table.Column<string>(maxLength: 50, nullable: true),
                    Town = table.Column<string>(maxLength: 50, nullable: true),
                    Location = table.Column<string>(maxLength: 100, nullable: true),
                    ZipCode = table.Column<string>(maxLength: 10, nullable: true),
                    QQ = table.Column<string>(maxLength: 15, nullable: true),
                    WX = table.Column<string>(maxLength: 50, nullable: true),
                    BirthDate = table.Column<DateTime>(nullable: true),
                    IDCardNo = table.Column<string>(maxLength: 20, nullable: true),
                    Gender = table.Column<int>(nullable: false),
                    BankName = table.Column<string>(maxLength: 50, nullable: true),
                    BankAccountName = table.Column<string>(maxLength: 20, nullable: true),
                    BankAccountNo = table.Column<string>(maxLength: 20, nullable: true),
                    BankAddress = table.Column<string>(maxLength: 60, nullable: true),
                    Comment = table.Column<string>(maxLength: 100, nullable: true),
                    StateNow = table.Column<int>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    TotalCashIn = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    TotalCashBonus = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    TotalCashOut = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    TotalCashBalance = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    TotalPointsIn = table.Column<int>(nullable: false),
                    TotalPointsOut = table.Column<int>(nullable: false),
                    TotalPointsBalance = table.Column<int>(nullable: false),
                    DebtLimit = table.Column<decimal>(type: "decimal(18,2)", nullable: false, defaultValueSql: "((0))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IMS_Partner", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "IMS_PartnerOAuth",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    OAuthID = table.Column<int>(nullable: false),
                    PartnerID = table.Column<int>(nullable: false),
                    Preferred = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IMS_PartnerOAuth", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Area",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 20, nullable: true),
                    PYCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Visible = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Area", x => x.ID)
                        .Annotation("SqlServer:Clustered", true);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Attachment",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TableID = table.Column<int>(nullable: false),
                    TableName = table.Column<string>(maxLength: 50, nullable: true),
                    InfoID = table.Column<int>(nullable: false),
                    FileType = table.Column<string>(maxLength: 50, nullable: true),
                    SrcName = table.Column<string>(maxLength: 150, nullable: true),
                    FileSize = table.Column<long>(nullable: false),
                    FileName = table.Column<string>(maxLength: 150, nullable: true),
                    FileUrl = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    FileDesc = table.Column<string>(maxLength: 50, nullable: true),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Attachment", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_AuditLog",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TableID = table.Column<int>(nullable: false),
                    InfoID = table.Column<int>(nullable: false),
                    AuditType = table.Column<int>(nullable: false),
                    AuditResult = table.Column<int>(nullable: false),
                    AuditRemark = table.Column<string>(maxLength: 32, nullable: true),
                    AuditDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AuditManID = table.Column<int>(nullable: false),
                    AuditManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_AuditLog", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_BuzRowNum",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    BuzType = table.Column<int>(nullable: false),
                    BuzTypeText = table.Column<string>(maxLength: 100, nullable: true),
                    Code = table.Column<string>(maxLength: 50, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: true),
                    RuleTpl = table.Column<string>(maxLength: 50, nullable: true),
                    MinLen = table.Column<int>(nullable: false),
                    Current = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    Step = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Freezed = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Sort = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_BuzRowNum", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Dept",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    PYCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Visible = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Dept", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Duty",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PID = table.Column<int>(nullable: false),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: true),
                    PYCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false),
                    Visible = table.Column<bool>(nullable: false),
                    Reserved = table.Column<bool>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Duty", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_EnumCode",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: true),
                    Value = table.Column<string>(maxLength: 500, nullable: true),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false, defaultValueSql: "((0))")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_EnumCode", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Express",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 20, nullable: true),
                    PYCode = table.Column<string>(maxLength: 10, nullable: true),
                    Url = table.Column<string>(maxLength: 150, nullable: true),
                    Sort = table.Column<int>(nullable: false),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Express", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Invoice",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Type = table.Column<int>(nullable: false),
                    CompanyName = table.Column<string>(maxLength: 80, nullable: true),
                    TaxCode = table.Column<string>(maxLength: 30, nullable: true),
                    DetailAddress = table.Column<string>(maxLength: 100, nullable: true),
                    Phone = table.Column<string>(maxLength: 20, nullable: true),
                    BankName = table.Column<string>(maxLength: 80, nullable: true),
                    BankNo = table.Column<string>(maxLength: 30, nullable: true),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Invoice", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Log",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ModuleID = table.Column<int>(nullable: false),
                    ModuleCode = table.Column<string>(maxLength: 32, nullable: true),
                    ModuleName = table.Column<string>(maxLength: 32, nullable: true),
                    ServiceID = table.Column<int>(nullable: false),
                    ServiceCode = table.Column<string>(maxLength: 32, nullable: true),
                    ServiceName = table.Column<string>(maxLength: 50, nullable: true),
                    ActionID = table.Column<int>(nullable: false),
                    ActionCode = table.Column<string>(maxLength: 32, nullable: true),
                    ActionName = table.Column<string>(maxLength: 50, nullable: true),
                    SrcUrl = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    LogType = table.Column<string>(maxLength: 32, nullable: true),
                    LogLevel = table.Column<int>(nullable: false),
                    LogContent = table.Column<string>(nullable: true),
                    LogTime = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LogManID = table.Column<int>(nullable: false),
                    LogManName = table.Column<string>(maxLength: 20, nullable: true),
                    LogManIP = table.Column<string>(unicode: false, maxLength: 40, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Log", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Module",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Icon = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Visible = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Module", x => x.ID)
                        .Annotation("SqlServer:Clustered", true);
                });

            migrationBuilder.CreateTable(
                name: "Sys_ModuleAction",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ServiceID = table.Column<int>(nullable: false),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: true),
                    Type = table.Column<string>(maxLength: 10, nullable: true),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Url = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    Target = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Icon = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    Visible = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_ModuleAction", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "Sys_ModuleService",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    ModuleID = table.Column<int>(nullable: false),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    Comment = table.Column<string>(maxLength: 200, nullable: true),
                    Tip = table.Column<string>(maxLength: 200, nullable: true),
                    Url = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    Type = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    Target = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Icon = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    Visible = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_ModuleService", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "Sys_OAuth",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AppID = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Type = table.Column<int>(nullable: false),
                    UserID = table.Column<int>(nullable: false),
                    UnionID = table.Column<string>(unicode: false, maxLength: 128, nullable: true),
                    OpenID = table.Column<string>(unicode: false, maxLength: 128, nullable: false),
                    NickName = table.Column<string>(maxLength: 50, nullable: true),
                    Gender = table.Column<int>(nullable: false),
                    Country = table.Column<string>(maxLength: 50, nullable: true),
                    Province = table.Column<string>(maxLength: 50, nullable: true),
                    City = table.Column<string>(maxLength: 50, nullable: true),
                    District = table.Column<string>(maxLength: 50, nullable: true),
                    Town = table.Column<string>(maxLength: 50, nullable: true),
                    DetailAddress = table.Column<string>(maxLength: 100, nullable: true),
                    AvatarUrl = table.Column<string>(maxLength: 200, nullable: true),
                    Authorized = table.Column<bool>(nullable: false),
                    Subscribed = table.Column<bool>(nullable: false),
                    SessionKey = table.Column<string>(maxLength: 200, nullable: true),
                    RelatedOAuthID = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LastUpdate = table.Column<DateTime>(nullable: false),
                    LastVisit = table.Column<DateTime>(nullable: false),
                    LastVisitIP = table.Column<string>(maxLength: 40, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_OAuth", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Organization",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Type = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    PID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    PartnerID = table.Column<int>(nullable: false),
                    PartnerName = table.Column<string>(maxLength: 120, nullable: true),
                    AreaID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: false),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    PYCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    LegalMan = table.Column<string>(maxLength: 50, nullable: true),
                    LegalManIDCardNo = table.Column<string>(maxLength: 20, nullable: true),
                    LegalManPhone = table.Column<string>(maxLength: 15, nullable: true),
                    ChargeMan = table.Column<string>(maxLength: 50, nullable: true),
                    ChargeManIDCardNo = table.Column<string>(maxLength: 20, nullable: true),
                    ChargeManPhone = table.Column<string>(maxLength: 15, nullable: true),
                    CertificateNo = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Phone = table.Column<string>(maxLength: 50, nullable: true),
                    Fax = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    EMail = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    ZipCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    Province = table.Column<string>(maxLength: 50, nullable: true),
                    City = table.Column<string>(maxLength: 50, nullable: true),
                    District = table.Column<string>(maxLength: 50, nullable: true),
                    Town = table.Column<string>(maxLength: 50, nullable: true),
                    DetailAddress = table.Column<string>(maxLength: 200, nullable: true),
                    Lng = table.Column<string>(maxLength: 50, nullable: true),
                    Lat = table.Column<string>(maxLength: 50, nullable: true),
                    Logo = table.Column<string>(maxLength: 200, nullable: true),
                    SiteUrl = table.Column<string>(maxLength: 200, nullable: true),
                    Comment = table.Column<string>(maxLength: 500, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    StateNow = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Organization", x => x.ID)
                        .Annotation("SqlServer:Clustered", true);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Role",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Code = table.Column<string>(unicode: false, maxLength: 32, nullable: false),
                    Name = table.Column<string>(maxLength: 50, nullable: false),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Freezed = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    Reserved = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    ChildVisible = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    StateNow = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Role", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_RoleAction",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RoleID = table.Column<int>(nullable: false),
                    ActionID = table.Column<int>(nullable: false),
                    ActionCode = table.Column<string>(maxLength: 32, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_RoleAction", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Session",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserID = table.Column<int>(unicode: false, nullable: false),
                    Type = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    SessionKey = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    RelatedOAuthID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddTime = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LastVisit = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LastVisitIP = table.Column<string>(unicode: false, maxLength: 40, nullable: true),
                    LastUpdate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Session", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_SmsLog",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TableID = table.Column<int>(nullable: false),
                    InfoID = table.Column<int>(nullable: false),
                    ReqUrl = table.Column<string>(maxLength: 2000, nullable: true),
                    ReqMethod = table.Column<string>(maxLength: 10, nullable: true),
                    ReqData = table.Column<string>(maxLength: 1000, nullable: true),
                    SmsState = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_SmsLog", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_TableLog",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    LogNo = table.Column<string>(maxLength: 32, nullable: true),
                    TableID = table.Column<int>(nullable: false),
                    InfoID = table.Column<int>(nullable: false),
                    LogType = table.Column<string>(maxLength: 32, nullable: true),
                    LogContent = table.Column<string>(nullable: true),
                    LogTime = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LogManID = table.Column<int>(nullable: false),
                    LogManName = table.Column<string>(maxLength: 20, nullable: true),
                    LogManIP = table.Column<string>(maxLength: 40, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_TableLog", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_User",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    RoleType = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    UserType = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    DeptID = table.Column<int>(nullable: false),
                    Code = table.Column<string>(unicode: false, maxLength: 100, nullable: false),
                    Passwd = table.Column<string>(unicode: false, maxLength: 64, nullable: true),
                    PasswdSalt = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Name = table.Column<string>(maxLength: 20, nullable: true),
                    PYCode = table.Column<string>(unicode: false, maxLength: 20, nullable: true),
                    IDCardNo = table.Column<string>(unicode: false, maxLength: 20, nullable: true),
                    NickName = table.Column<string>(maxLength: 50, nullable: true),
                    Gender = table.Column<int>(nullable: false, defaultValueSql: "((1))"),
                    Phone = table.Column<string>(unicode: false, maxLength: 20, nullable: true),
                    Mobile = table.Column<string>(unicode: false, maxLength: 15, nullable: true),
                    Email = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Nation = table.Column<string>(maxLength: 10, nullable: true),
                    Country = table.Column<string>(maxLength: 50, nullable: true),
                    Province = table.Column<string>(maxLength: 50, nullable: true),
                    City = table.Column<string>(maxLength: 50, nullable: true),
                    District = table.Column<string>(maxLength: 50, nullable: true),
                    Town = table.Column<string>(maxLength: 50, nullable: true),
                    DetailAddress = table.Column<string>(maxLength: 100, nullable: true),
                    ZipCode = table.Column<string>(unicode: false, maxLength: 10, nullable: true),
                    AvatarUrl = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    BirthDate = table.Column<DateTime>(nullable: true),
                    QQ = table.Column<string>(unicode: false, maxLength: 15, nullable: true),
                    WX = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    WorkUnit = table.Column<string>(maxLength: 100, nullable: true),
                    StateNow = table.Column<int>(nullable: false, defaultValueSql: "((4))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    LastLoginIP = table.Column<string>(unicode: false, maxLength: 40, nullable: true),
                    LastLoginDate = table.Column<DateTime>(nullable: true),
                    OrgID = table.Column<int>(nullable: false),
                    PrinterName = table.Column<string>(maxLength: 80, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_User", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_UserAddress",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserID = table.Column<string>(type: "char(32)", nullable: false),
                    Type = table.Column<int>(nullable: false, defaultValueSql: "((5))"),
                    Name = table.Column<string>(maxLength: 20, nullable: true),
                    Mobile = table.Column<string>(unicode: false, maxLength: 15, nullable: true),
                    Province = table.Column<string>(maxLength: 50, nullable: true),
                    ProvinceID = table.Column<string>(maxLength: 32, nullable: true),
                    City = table.Column<string>(maxLength: 50, nullable: true),
                    CityID = table.Column<string>(maxLength: 32, nullable: true),
                    District = table.Column<string>(maxLength: 50, nullable: true),
                    DistrictID = table.Column<string>(maxLength: 32, nullable: true),
                    Town = table.Column<string>(maxLength: 50, nullable: true),
                    TownID = table.Column<string>(maxLength: 32, nullable: true),
                    DetailAddress = table.Column<string>(maxLength: 100, nullable: true),
                    ZipCode = table.Column<string>(unicode: false, maxLength: 6, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Preferred = table.Column<bool>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    LastModifyDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LastModifyManID = table.Column<int>(nullable: false),
                    LastModifyManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_UserAddress", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_UserBankCard",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserID = table.Column<int>(nullable: false),
                    BankName = table.Column<string>(maxLength: 50, nullable: true),
                    AccountName = table.Column<string>(maxLength: 20, nullable: true),
                    AccountNo = table.Column<string>(maxLength: 20, nullable: true),
                    BankAddress = table.Column<string>(maxLength: 60, nullable: true),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    LastModifyDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    LastModifyManID = table.Column<int>(nullable: false),
                    LastModifyManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_UserBankCard", x => x.ID)
                        .Annotation("SqlServer:Clustered", false);
                });

            migrationBuilder.CreateTable(
                name: "Sys_UserOAuth",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    OAuthID = table.Column<int>(nullable: false),
                    UserID = table.Column<int>(nullable: false),
                    Preferred = table.Column<bool>(nullable: false, defaultValueSql: "('0')"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_UserOAuth", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "Sys_UserRole",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    UserID = table.Column<int>(nullable: false),
                    RoleID = table.Column<int>(nullable: false),
                    AuthValid = table.Column<bool>(nullable: false, defaultValueSql: "('1')"),
                    AuthExpireDate = table.Column<DateTime>(nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_UserRole", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_AppConfig",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AppID = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    AppName = table.Column<string>(maxLength: 20, nullable: true),
                    AppDesc = table.Column<string>(maxLength: 50, nullable: true),
                    AppSecret = table.Column<string>(maxLength: 32, nullable: true),
                    AppToken = table.Column<string>(maxLength: 32, nullable: true),
                    MchID = table.Column<string>(maxLength: 32, nullable: true),
                    MchKey = table.Column<string>(maxLength: 32, nullable: true),
                    NotifyUrl = table.Column<string>(maxLength: 256, nullable: true),
                    EncodingAESKey = table.Column<string>(maxLength: 50, nullable: true),
                    AppType = table.Column<int>(nullable: false),
                    Domain = table.Column<string>(maxLength: 80, nullable: true),
                    SvrIP = table.Column<string>(maxLength: 64, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true),
                    OrgID = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_AppConfig", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_Log",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Type = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    LogDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    TplID = table.Column<string>(maxLength: 32, nullable: true),
                    Url = table.Column<string>(unicode: false, maxLength: 100, nullable: true),
                    LogContent = table.Column<string>(nullable: true),
                    LogManID = table.Column<int>(nullable: false),
                    LogManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_Log", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_Menu",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    PID = table.Column<string>(type: "char(32)", nullable: false),
                    Code = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Name = table.Column<string>(maxLength: 10, nullable: true),
                    Type = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AppID = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Url = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    PagePath = table.Column<string>(unicode: false, maxLength: 300, nullable: true),
                    MediaID = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_Menu", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_PayOrder",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    OutTradeNO = table.Column<string>(maxLength: 32, nullable: true),
                    AppID = table.Column<string>(maxLength: 32, nullable: true),
                    MchID = table.Column<string>(maxLength: 32, nullable: true),
                    TradeType = table.Column<string>(maxLength: 16, nullable: true),
                    TradeState = table.Column<string>(maxLength: 32, nullable: true),
                    TradeStateDesc = table.Column<string>(maxLength: 256, nullable: true),
                    ErrorCode = table.Column<string>(maxLength: 32, nullable: true),
                    ErrorMsg = table.Column<string>(maxLength: 128, nullable: true),
                    OpenID = table.Column<string>(maxLength: 128, nullable: false),
                    PrepayID = table.Column<string>(maxLength: 64, nullable: true),
                    DeviceInfo = table.Column<string>(maxLength: 32, nullable: true),
                    BankType = table.Column<string>(maxLength: 16, nullable: true),
                    DuePay = table.Column<int>(nullable: false),
                    TotalFee = table.Column<int>(nullable: false),
                    SettlementTotalFee = table.Column<int>(nullable: false),
                    CashFee = table.Column<int>(nullable: false),
                    CouponFee = table.Column<int>(nullable: false),
                    CouponCount = table.Column<int>(nullable: false),
                    TransactionID = table.Column<string>(maxLength: 32, nullable: true),
                    Attach = table.Column<string>(maxLength: 32, nullable: true),
                    TimeStart = table.Column<DateTime>(nullable: false),
                    TimeEnd = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_PayOrder", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_Session",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AppID = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    OpenID = table.Column<string>(unicode: false, maxLength: 128, nullable: true),
                    UnionID = table.Column<string>(unicode: false, maxLength: 128, nullable: true),
                    ExpireDate = table.Column<DateTime>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    StateNow = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_Session", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "WX_TplMsgConfig",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    AppID = table.Column<string>(unicode: false, maxLength: 32, nullable: true),
                    Type = table.Column<int>(nullable: false),
                    Code = table.Column<string>(unicode: false, maxLength: 50, nullable: true),
                    Title = table.Column<string>(maxLength: 10, nullable: true),
                    Url = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    XCXID = table.Column<string>(maxLength: 30, nullable: true),
                    XCXPagePath = table.Column<string>(unicode: false, maxLength: 300, nullable: true),
                    Tpl = table.Column<string>(maxLength: 1000, nullable: true),
                    Example = table.Column<string>(maxLength: 2000, nullable: true),
                    Sort = table.Column<int>(nullable: false, defaultValueSql: "((0))"),
                    Comment = table.Column<string>(maxLength: 50, nullable: true),
                    StateNow = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_TplMsgConfig", x => x.ID)
                        .Annotation("SqlServer:Clustered", true);
                });

            migrationBuilder.CreateTable(
                name: "WX_TplMsgLog",
                columns: table => new
                {
                    ID = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    TplID = table.Column<int>(nullable: false),
                    TplCode = table.Column<string>(unicode: false, maxLength: 50, nullable: false),
                    TplData = table.Column<string>(maxLength: 1000, nullable: true),
                    AppID = table.Column<string>(maxLength: 32, nullable: true),
                    OpenID = table.Column<string>(maxLength: 128, nullable: false),
                    Url = table.Column<string>(unicode: false, maxLength: 200, nullable: true),
                    XCXID = table.Column<string>(unicode: false, maxLength: 30, nullable: true),
                    XCXPagePath = table.Column<string>(unicode: false, maxLength: 300, nullable: true),
                    RemindState = table.Column<int>(nullable: false),
                    AddDate = table.Column<DateTime>(nullable: false, defaultValueSql: "(getdate())"),
                    AddManID = table.Column<int>(nullable: false),
                    AddManName = table.Column<string>(maxLength: 20, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WX_TplMsgLog", x => x.ID)
                        .Annotation("SqlServer:Clustered", true);
                });

            migrationBuilder.CreateIndex(
                name: "IX_IMS_Partner_Type",
                table: "IMS_Partner",
                column: "Type")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_PartnerOAuth_OAuthID",
                table: "IMS_PartnerOAuth",
                column: "OAuthID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_IMS_PartnerOAuth_PartnerID",
                table: "IMS_PartnerOAuth",
                column: "PartnerID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Area_PID",
                table: "Sys_Area",
                column: "PID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Attachment_TableID_InfoID",
                table: "Sys_Attachment",
                columns: new[] { "TableID", "InfoID" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_BuzRowNum_BuzType_Code",
                table: "Sys_BuzRowNum",
                columns: new[] { "BuzType", "Code" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Dept_OrgID",
                table: "Sys_Dept",
                column: "OrgID")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Dept_PID",
                table: "Sys_Dept",
                column: "PID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_EnumCode_Code",
                table: "Sys_EnumCode",
                column: "Code")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "PK_Sys_Module_Code",
                table: "Sys_Module",
                column: "Code")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "PK_Sys_ModuleAction_Code",
                table: "Sys_ModuleAction",
                column: "Code")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "PK_Sys_ModuleAction_ServiceID",
                table: "Sys_ModuleAction",
                column: "ServiceID")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_ModuleService_Code",
                table: "Sys_ModuleService",
                column: "Code")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_ModuleService_ModuleID",
                table: "Sys_ModuleService",
                column: "ModuleID")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_OAuth_AppID_OpenID",
                table: "Sys_OAuth",
                columns: new[] { "AppID", "OpenID" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Organization_AreaID",
                table: "Sys_Organization",
                column: "AreaID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Organization_Code",
                table: "Sys_Organization",
                column: "Code")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_RoleAction_RoleID_ActionID",
                table: "Sys_RoleAction",
                columns: new[] { "RoleID", "ActionID" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_Session_UserID_Type",
                table: "Sys_Session",
                columns: new[] { "UserID", "Type" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_SmsLog_SmsState",
                table: "Sys_SmsLog",
                column: "SmsState")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_TableLog_TableID_InfoID",
                table: "Sys_TableLog",
                columns: new[] { "TableID", "InfoID" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_User_Code",
                table: "Sys_User",
                column: "Code",
                unique: true)
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_User_OrgID",
                table: "Sys_User",
                column: "OrgID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_UserAddress",
                table: "Sys_UserAddress",
                column: "UserID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_UserBankCard_UserID",
                table: "Sys_UserBankCard",
                column: "UserID")
                .Annotation("SqlServer:Clustered", true);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_UserOAuth_OAuthID",
                table: "Sys_UserOAuth",
                column: "OAuthID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_UserOAuth_UserID",
                table: "Sys_UserOAuth",
                column: "UserID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_UserRole_UserID_RoleID",
                table: "Sys_UserRole",
                columns: new[] { "UserID", "RoleID" },
                unique: true)
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_WX_AppConfig_AppID",
                table: "WX_AppConfig",
                column: "AppID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_Sys_WXSessionMap_AppID_OpenID",
                table: "WX_Session",
                columns: new[] { "AppID", "OpenID" })
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_WX_TplMsgConfig_AppID",
                table: "WX_TplMsgConfig",
                column: "AppID")
                .Annotation("SqlServer:Clustered", false);

            migrationBuilder.CreateIndex(
                name: "IX_WX_TplMsgLog_RemindState",
                table: "WX_TplMsgLog",
                column: "RemindState")
                .Annotation("SqlServer:Clustered", false);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "IMS_Partner");

            migrationBuilder.DropTable(
                name: "IMS_PartnerOAuth");

            migrationBuilder.DropTable(
                name: "Sys_Area");

            migrationBuilder.DropTable(
                name: "Sys_Attachment");

            migrationBuilder.DropTable(
                name: "Sys_AuditLog");

            migrationBuilder.DropTable(
                name: "Sys_BuzRowNum");

            migrationBuilder.DropTable(
                name: "Sys_Dept");

            migrationBuilder.DropTable(
                name: "Sys_Duty");

            migrationBuilder.DropTable(
                name: "Sys_EnumCode");

            migrationBuilder.DropTable(
                name: "Sys_Express");

            migrationBuilder.DropTable(
                name: "Sys_Invoice");

            migrationBuilder.DropTable(
                name: "Sys_Log");

            migrationBuilder.DropTable(
                name: "Sys_Module");

            migrationBuilder.DropTable(
                name: "Sys_ModuleAction");

            migrationBuilder.DropTable(
                name: "Sys_ModuleService");

            migrationBuilder.DropTable(
                name: "Sys_OAuth");

            migrationBuilder.DropTable(
                name: "Sys_Organization");

            migrationBuilder.DropTable(
                name: "Sys_Role");

            migrationBuilder.DropTable(
                name: "Sys_RoleAction");

            migrationBuilder.DropTable(
                name: "Sys_Session");

            migrationBuilder.DropTable(
                name: "Sys_SmsLog");

            migrationBuilder.DropTable(
                name: "Sys_TableLog");

            migrationBuilder.DropTable(
                name: "Sys_User");

            migrationBuilder.DropTable(
                name: "Sys_UserAddress");

            migrationBuilder.DropTable(
                name: "Sys_UserBankCard");

            migrationBuilder.DropTable(
                name: "Sys_UserOAuth");

            migrationBuilder.DropTable(
                name: "Sys_UserRole");

            migrationBuilder.DropTable(
                name: "WX_AppConfig");

            migrationBuilder.DropTable(
                name: "WX_Log");

            migrationBuilder.DropTable(
                name: "WX_Menu");

            migrationBuilder.DropTable(
                name: "WX_PayOrder");

            migrationBuilder.DropTable(
                name: "WX_Session");

            migrationBuilder.DropTable(
                name: "WX_TplMsgConfig");

            migrationBuilder.DropTable(
                name: "WX_TplMsgLog");
        }
    }
}
